package lg.minecraft.plugin.entityclear.parser;

import lg.minecraft.plugin.entityclear.component.ComponentType;
import lombok.Getter;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.logging.Level;
import java.util.logging.Logger;

@Getter
public class ParserContext {

    @NotNull private final Plugin plugin;
    @NotNull private final Logger logger;
    @Nullable private final ConfigurationSection config;
    @NotNull private final String parserName;
    @NotNull private final ComponentType componentType;

    public ParserContext(@NotNull Plugin plugin, @Nullable ConfigurationSection config, @NotNull String parserName, @NotNull ComponentType componentType) {
        this.config = config;
        this.plugin = plugin;
        this.logger = plugin.getLogger();
        this.parserName = parserName;
        this.componentType = componentType;
    }

    public void info(String message, Object... object) {
        logger.log(Level.INFO, "[" + componentType.name + "][" + parserName + "] " + message, object);
    }

    public void info(String message, Throwable thrown) {
        logger.log(Level.INFO, "[" + componentType.name + "][" + parserName + "] " + message, thrown);
    }

    public void warning(String message, Object... object) {
        logger.log(Level.WARNING, "[" + componentType.name + "][" + parserName + "] " + message, object);
    }

    public void warning(String message, Throwable thrown) {
        logger.log(Level.INFO, "[" + componentType.name + "][" + parserName + "] " + message, thrown);
    }

    public void severe(String message, Object... object) {
        logger.log(Level.SEVERE, "[" + componentType.name + "][" + parserName + "] " + message, object);
    }

    public void severe(String message, Throwable thrown) {
        logger.log(Level.INFO, "[" + componentType.name + "][" + parserName + "] " + message, thrown);
    }

}
